package com.abc.service.impl;

import com.abc.entity.ProgramType;
import com.abc.entity.Programme;
import com.abc.mapper.ProgramTypeMapper;
import com.abc.mapper.ProgrammeMapper;
import com.abc.service.IProgramTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2024-12-25
 */
@Service
public class ProgramTypeServiceImpl extends ServiceImpl<ProgramTypeMapper, ProgramType> implements IProgramTypeService {
    @Autowired
    private ProgrammeMapper programmeMapper;

    @Override
    public boolean addReminder(ProgramType programType, Integer programmeId) {
        Programme programme = programmeMapper.selectById(programmeId);
        if (programme != null) {
            programType.setReminderId(programmeId);
            return this.save(programType);
        } else {
            return false;
        }
    }

    @Override
    public boolean deleteReminder(Integer reminderId, Integer programmeId) {
        ProgramType programType = this.getById(reminderId);
        if (programType.getReminderId().equals(programmeId)) {
            return this.removeById(reminderId);
        } else {
            return false;
        }
    }
}
